home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / develop / libsrc11.arc / RDBYTSPI.C < prev    next >
C/C++ Source or Header  |  1989-04-27  |  846b  |  36 lines

  1. /*    rdbytspi.c 4.4        */
  2. /*F****************************************************************************
  3.  
  4. FUNCTION NAME:    rdbytspi
  5.  
  6. ACTION:        Reads a character from the SPI serial hardware.  Returns
  7.         an integer.  The upper byte of the integer returned is the
  8.         SPI status register.  The lower byte is the SPI data register.
  9.  
  10. PARAMETERS:    (None)
  11.  
  12. RETURNS:    (int)
  13.  
  14. ******************************************************************************/
  15.  
  16. #include <hc11/io.h>
  17. #include <hc11/spi.h>
  18. #include <hc11/directives.h>
  19.  
  20. SMALL
  21. unsigned rdbytspi()
  22.  
  23.     {
  24.  
  25.     HC11.SPCR |= SPE;
  26.  
  27.     if (HC11.SPCR & MSTR)
  28.         HC11.SPSRDAT.DATAREG = HC11.SPSRDAT.DATAREG ; /* for loopback */
  29.  
  30.     while ((HC11.SPSRDAT.STATUS & SPIF) == 0)
  31.         ;        /* null statement */
  32.  
  33.     return (HC11.SPSRDAT.STATDATA);    /* return status and data */
  34.  
  35.     }    /* end of rdbytspi    */
  36.